#pragma once
namespace zzb
{
	template<class K, class T>
	class map
	{
	public:
		struct KeyOfMap
		{
			const K& operator()(const pair<K, T>& data)
			{
				return data.first;
			}
		};
		typedef typename RBTree<K, pair<const K, T>, KeyOfMap>::iterator iterator;
		typedef typename RBTree<K, pair<const K, T>, KeyOfMap>::const_iterator const_iterator;

		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		const_iterator begin() const
		{
			return _t.begin();
		}
		const_iterator end() const
		{
			return _t.end();
		} 
		pair<iterator, bool> insert(const  pair<K, T>& data)
		{
			return _t.insert(data);
		}
		T& operator[](const K& k)
		{
			return (insert(make_pair(k, T())).first)->second;
		}
		int size()
		{
			return _t.size();
		}
		void PostOrder()
		{
			_t.PostOrder();
		}
	private:
		RBTree<K, pair<const K, T>, KeyOfMap> _t;
	};
}